package com.jiuyin.dianjing.util;

import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.view.WindowManager;

import com.jiuyin.dianjing.app.HelperApplication;

public class WindowDispaly {
    static WindowManager wm;

    /**
     * 获取真实屏幕高度
     *
     * @return
     */
    public static int getRealHeight() {
        if (null == wm) {
            wm = (WindowManager) HelperApplication.getContext().getSystemService(Context.WINDOW_SERVICE);
        }
        Point point = new Point();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            wm.getDefaultDisplay().getRealSize(point);
        } else {
            wm.getDefaultDisplay().getSize(point);
        }
        return point.y;
    }

    /**
     * 获取状态栏高度
     *
     * @return
     */
    public static int getStatusBarHeight() {
        int result = 0;
        int resourceId = HelperApplication.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = HelperApplication.getContext().getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }
}
